<?php
namespace uploadPic;

class UploadPic{
	
	//uploads pictures to server /../uploads
	public function uploadCurrentPic(){
		
		//if they DID upload a file...
		if($_FILES['photo']['name'])
		{
			//if no errors...
			if(!$_FILES['photo']['error'])
			{
				$new_file_name = strtolower($_FILES['photo']['tmp_name']);
				$valid_file = TRUE;
				if($_FILES['photo']['size'] > (1024000)) //can't be larger than 1 MB
				{
					$valid_file = false;
					echo 'Oops!  Your file\'s size is to large.';
				}else {
					
				}

				if($valid_file)
				{
					$currentdir = getcwd();
					$target = $currentdir . "/model/uploads/" . basename($_FILES['photo']['name']);
					move_uploaded_file($_FILES['photo']['tmp_name'], $target);	
				}
			}
			else
			{
				echo 'Ooops!  Your upload triggered the following error:  '.$_FILES['photo']['error'];
			}
		}
	}
	
}
